home *** CD-ROM | disk | FTP | other *** search
- #include "fish.h"
-
- #define TIMER 2
-
- #include "collaris.h"
- #define COLLARIS_ANIME 9
- #define COLLARIS_Y 150
- #define COLLARIS_DX 1
- #define COLLARIS_DT 1
- #define COLLARIS_SIZE (collaris_width*collaris_height)
- unsigned char collaris_save[COLLARIS_SIZE * sizeof (short)];
-
- #include "blueking.h"
- #define BLUEKING_ANIME 8
- #define BLUEKING_Y 70
- #define BLUEKING_DX 2
- #define BLUEKING_DT 1
- #define BLUEKING_SIZE (blueking_width*blueking_height)
- unsigned char blueking_save[BLUEKING_SIZE * sizeof (short)];
-
- struct fish fishes[] = {
- { COLLARIS_ANIME, COLLARIS_Y, COLLARIS_DX, COLLARIS_DT,
- collaris_width, collaris_height, collaris_n_raster,
- collaris_colors, collaris_color16, collaris_color4,
- collaris_rasters, collaris_save,
- },
- { BLUEKING_ANIME, BLUEKING_Y, BLUEKING_DX, BLUEKING_DT,
- blueking_width, blueking_height, blueking_n_raster,
- blueking_colors, blueking_color16, blueking_color4,
- blueking_rasters, blueking_save,
- }
- };
- #define N_FISH (sizeof fishes / sizeof (struct fish))
- #define N_FISH_AT_ONCE 2
-
- int fish_first = TRUE, fish_count = 1;
- int timer = TIMER;
- int anime1 = COLLARIS_ANIME;
- int ypos1 = COLLARIS_Y;
- int dx1 = COLLARIS_DX;
- int dt1 = COLLARIS_DT;
- int anime2 = BLUEKING_ANIME;
- int ypos2 = BLUEKING_Y;
- int dx2 = BLUEKING_DX;
- int dt2 = BLUEKING_DT;
-
- void fishmain()
- {
- int n;
- struct fish *p;
- static int id = 0;
- extern int aplid, active, restart, unmapped;
- extern short vramseg;
- extern int pixel, vheight, dwidth;
- extern int _setfs();
- extern void mkcolor(), draw16(), draw4(), map();
-
- if (!active)
- return;
-
- if (fish_first){
- fishes[0].cnt_init = anime1;
- fishes[0].y = ypos1;
- fishes[0].dx = dx1;
- fishes[0].dt = dt1;
- fishes[1].cnt_init = anime2;
- fishes[1].y = ypos2;
- fishes[1].dx = dx2;
- fishes[1].dt = dt2;
- }
- /* speed control timer */
- if (--fish_count > 0)
- return;
- fish_count = timer;
-
- _setfs(vramseg);
- if (restart){
- restart = FALSE;
- p = fishes;
- n = N_FISH;
- while (--n >= 0){
- p->index = 0;
- p->cnt = 1;
- p->timer = 1;
- p->win.x = -p->width + 1;
- p->win.w = p->width;
- p->win.h = p->h;
- p->win.save = p->save;
- p->win.owner = (void *)p;
- p->win.mapped = FALSE;
- if (pixel == 16){ /* 15bit-color */
- p->w = p->width + p->width; /* byte */
- p->x_max = dwidth - 1;
- p->color = (unsigned char *)p->color16;
- if (vheight < 512)
- p->win.y = p->y;
- else
- p->win.y = p->y + (p->y >> 1); /* x 1.5 */
- p->win.draw = draw16;
- } else if (pixel == 4){ /* 4bit-color */
- p->w = p->width; /* byte */
- p->x_max = dwidth - 1;
- mkcolor(p->n_color, p->color16, p->color4);
- p->color = p->color4;
- if (vheight < 1024)
- p->win.y = p->y * 2;
- else
- p->win.y = p->y * 3;
- p->win.draw = draw4;
- }
- p->save_size = p->w * p->h;
- p->win.size = p->save_size;
- if (fish_first){
- p->win.aplid = aplid;
- winCreate(&p->win);
- }
- winMap(&p->win);
- p++;
- }
- id = 0;
- }
- if (fish_first)
- fish_first = FALSE;
-
- if (unmapped)
- map(TRUE);
-
- if ((n = N_FISH) > N_FISH_AT_ONCE)
- n = N_FISH_AT_ONCE;
- while (--n >= 0){
- p = fishes + id;
- if (--p->timer == 0){ /* fish speed control timer */
- p->timer = p->dt;
- winMove(&p->win, p->win.x + p->dx, p->win.y);
- if (p->win.x > p->x_max)
- winMove(&p->win, -p->width+1, p->win.y);
- if (--p->cnt == 0){ /* animation counter */
- p->cnt = p->cnt_init;
- if (++p->index == p->n_raster)
- p->index = 0;
- }
- }
- if (++id == N_FISH)
- id = 0;
- }
- }
-
- void fish_init()
- {
- int i;
- struct fish *p;
-
- for (i = 0, p = fishes; i < N_FISH; i++, p++)
- p->index = -1;
- }
-
- void map(int map)
- {
- int i;
- struct fish *p;
- extern int unmapped;
-
- for (i = 0, p = fishes; i < N_FISH; i++, p++){
- if (p->index >= 0){
- if (map)
- winMap(&p->win);
- else
- winUnmap(&p->win);
- }
- }
- unmapped = !map;
- }
-
- void terminate()
- {
- int i;
- struct fish *p;
-
- for (i = 0, p = fishes; i < N_FISH; i++, p++){
- if (p->index >= 0){
- winUnmap(&p->win);
- winDestroy(&p->win);
- p->index = -1;
- }
- }
- }
-